﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ElectronicSelling.BaseEntity;
using System.Data;
using System.Data.SqlClient;

namespace ElectronicSelling.DataAccess
{
    public class HomeAccountAccess
    {
        public static DataTable GetUserLogin(User user)
        {
            DataTable dt = DataAccess.ExeStoredWithParamToDataTable(
                "usp_UserSelectToLogin", "@UserName", user.UserName, "@Password", user.Password);
            return dt;
        }

        public static DataTable GetExistCustomer(User user)
        {
            DataTable dt = DataAccess.ExeStoredWithParamToDataTable(
                "usp_UserSelectByUserName", "@UserName", user.UserName
                );
            return dt;
        }

        public static bool InsertCustomer(User user)
        {
            return DataAccess.ExeStoredWithParamToBool(
                "usp_CustomerInsert", "@UserName", user.UserName,
                "@Password", user.Password,
                "@FullName", user.FullName,
                "@DateOfBirth", user.DateOfBirth,
                "@Email", user.Email,
                "@Address", user.Address,
                "@Phone", user.Phone
                );
        }

        public static DataTable GetCustomerDetail(User user)
        {
            return DataAccess.ExeStoredWithParamToDataTable(
                "usp_CustomerSelectById", "@UserId", user.UserId);
        }

        public static bool UpdateCustomerForOrder(User user)
        {
            return DataAccess.ExeStoredWithParamToBool(
                "usp_CustomerUpDateForOrder",
                "@UserId", user.UserId,
                "@FullName", user.FullName,
                "@Gender", user.Gender,
                "@Phone", user.Phone,
                "@DateOfBirth", user.DateOfBirth,
                "@Email", user.Email,
                "@Address", user.Address
                );
        }

        public static DataTable GetPassWordById(User user)
        {
            return DataAccess.ExeStoredWithParamToDataTable("usp_UserOldPassSelectById", "@UserId", user.UserId);
        }

        public static bool IsUpdatePassword(User user)
        {
            return DataAccess.ExeStoredWithParamToBool("usp_UserChangePassById", "@UserId", user.UserId, "@NewPass", user.Password);
        }

        public static bool IsUpdateCustomer(User user)
        {
            return DataAccess.ExeStoredWithParamToBool("usp_CustomerUpDateInfo", "@UserId", user.UserId, "@FullName", user.FullName, "@Gender", user.Gender, "@Phone", user.Phone, "@PhonePreventive", user.PhonePreventive, "@DateOfBirth", user.DateOfBirth, "@Email", user.Email, "@Address", user.Address);
        }

    }
}
